#include <bits/stdc++.h>
#define ll long long
#define Lb long double
using namespace std;
const int N = 1e5 + 5, M = 1e6 + 5;
const Lb eps = 1e-7;

int T, n, m, L, V;
int d[N], v[N], a[N];
int lft[M], rgt[M], p[N];

struct seg { int l, r, id; } s[N];
bool cmp(seg x, seg y) {
    if(x.l != y.l) return x.l < y.l;
    return x.r < y.r;
}

int cover(int ln) {
    sort(s + 1, s + ln + 1, cmp);
    int mn = -1e9, ans = 0;
    for(int i = 1; i <= ln; i++) {
        if(s[i].l > mn) {
            mn = s[i].r;
            ans++;
        }
        else mn = min(mn, s[i].r);
    }
    return ans;
}

int Lft(int x) {
    if(x < 0) return 0;
    if(x > L) return m;
    return lft[x];
}
int Rgt(int x) {
    if(x < 0) return 1;
    if(x > L) return m + 1;
    return rgt[x];
}

void solve() {
    cin >> n >> m >> L >> V;
    for(int i = 1; i <= n; i++)
        cin >> d[i] >> v[i] >> a[i];

    memset(lft, 0, sizeof lft);
    memset(rgt, 0, sizeof rgt);

    for(int i = 1; i <= m; i++) {
        cin >> p[i];
        lft[p[i]] = rgt[p[i]] = i;
    }
    rgt[L + 1] = m + 1;

    for(int i = 1; i <= L; i++)
        if(!lft[i]) lft[i] = lft[i - 1];
    for(int i = L; i >= 1; i--)
        if(!rgt[i]) rgt[i] = rgt[i + 1];

    int tot = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] == 0) {
            if(v[i] > V && rgt[d[i]] <= m) s[++tot] = {rgt[d[i]], m, i};
        }
        else {
            Lb x = d[i] + ((Lb)V * V - (Lb)v[i] * v[i]) / (2 * a[i]);

            if(a[i] > 0) {
                ll xx = (ll)ceil(x + eps);
                if(max(Rgt(d[i]), Rgt(xx)) <= m) s[++tot] = {max(Rgt(d[i]), Rgt(xx)), m, i};
            }
            else {
                ll xx = (ll)floor(x - eps);
                if(Lft(xx) >= rgt[d[i]]) s[++tot] = {rgt[d[i]], Lft(xx), i};
            }
        }
    }
    cout << tot << ' ' << m - cover(tot) << endl;
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while(T--) solve();
    return 0;
}
